home *** CD-ROM | disk | FTP | other *** search
/ C# & Game Programming - A…er's Guide (2nd Edition) / Buono 2nd Ed.iso / GameClasses / GameState.cs < prev    next >
Text File  |  2004-09-07  |  2KB  |  57 lines

  1. /* GameState.cs: Contains the GameState class which is responsible for
  2.  * maintaining simple state information about a game such as the speed,
  3.  * state (started, stopped, etc) and mode (demo, single player, etc.).
  4.  */
  5.  
  6. using System;
  7.  
  8. namespace GameClasses {
  9.     public class GameState { 
  10.      // Different speeds the game can be run in.
  11.         public const int SPEED_MINIMUM = 1;
  12.         public const int SPEED_DEFAULT = 3;
  13.         public const int SPEED_MAXIMUM = 10;
  14.  
  15.         // Different "states" the game can be in.
  16.         public enum State : int {
  17.             Unknown = 0,
  18.             Started = 1,
  19.             Stopped = 2,
  20.         }
  21.  
  22.         // Different "modes" the game can be run in.
  23.         [Flags] 
  24.             public enum Mode : int {
  25.             Normal = 0,
  26.             SinglePlayer = 0,
  27.             TwoPlayer = 1,
  28.             Demo = 2,
  29.         }
  30.     
  31.         // Member variables
  32.         public int currentSpeed;
  33.         public State currentState;
  34.         public Mode currentMode;
  35.  
  36.         // Constructors
  37.         public GameState() {
  38.             currentSpeed = SPEED_DEFAULT;
  39.             currentState = State.Stopped;
  40.             currentMode = Mode.Normal;
  41.         }
  42.  
  43.         public GameState(int initialSpeed, State gameState) {
  44.             currentSpeed = initialSpeed;
  45.             currentState = gameState;
  46.             currentMode = Mode.Normal;
  47.         }
  48.  
  49.         public GameState(int initialSpeed, State gameState, 
  50.             Mode gameMode) {
  51.             currentSpeed = initialSpeed;
  52.             currentState = gameState;
  53.             currentMode = gameMode;
  54.         }
  55.     }
  56. }
  57.